window.onload=function(){
    let data=new FormData();
    let name =sessionStorage.getItem('username')
    $('.select').click(function(){
        $('.file').click()
    })
    $('.file').on('change',function(){
        let reader=new FileReader();
        data.append('file',this.files[0])
        console.log(data);
        reader.readAsDataURL(this.files[0]);
        reader.onload=function(e){
            $('.img').attr('src',e.target.result)}
    })
    $('.upload').click(function(){
        console.log(data);
        $.ajax({
            url:'/sider/upload',
            method:'post',
            data:data,
            contentType:false,
            processData:false,
            success:function(data){
                if(data){
                    location.href='../../pages/xitongshouye--shikaiwen/shouye.html'
                }
            }
        })
    })
}